package com.example.webviewlauncher;

import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {
    private static final String PACKAGE = "com.example.tvscreendisplay";
    private static final String ACTIVITY = ".MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        EdgeToEdge.enable(this);
//        setContentView(R.layout.activity_main);
//        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
//            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
//            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
//            return insets;
//        });

        // 判断 AndroidTV-DSvideo 是否安装
        PackageManager pm = getPackageManager();
        boolean isInstalled = false;
        try {
            pm.getPackageInfo(PACKAGE, PackageManager.GET_ACTIVITIES);
            isInstalled = true;
        } catch (PackageManager.NameNotFoundException e) {
            Log.d("----","ERROR"+e.toString());
        }

        if (isInstalled) {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName(PACKAGE, PACKAGE + ACTIVITY));
            startActivity(intent);
        }

        finish();

    }
}